﻿//------------------------------------------------赵洪科-----------------------------------------------//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///Transaction 的摘要说明
/// </summary>
public partial class Transaction
{
    DataTableDataContext db = new DataTableDataContext();
    //增加到Transaction
    public void insertTo(decimal pay, int id, string c)
    {
        Transaction trade = new Transaction
        {
            payment = pay,
            memberId = id,
            city = c,
            createDate = System.DateTime.Now,
        };
        db.Transaction.InsertOnSubmit(trade);
        db.SubmitChanges();
    }

    //删除Transaction的某一订单信息
    public void removeFr(int id1)
    {
        var trades = from b in db.Transaction where b.transactionId == id1 select b;
        foreach (var trade in trades)
        {
            db.Transaction.DeleteOnSubmit(trade);
            db.SubmitChanges();
        }
    }

    //根据TransactionID查找某记录（订单）
    public IEnumerable<Transaction> returnFr(int id1)
    {
        var trade = from b in db.Transaction where b.transactionId == id1 select b;
        return trade;
    }

    //根据memberId查找某记录（订单）
    public IEnumerable<Transaction> returnfr(int id1)
    {
        var trade = from b in db.Transaction where b.memberId == id1 select b;
        return trade;
    }

    //根据CreateDate查找某记录（订单）
    public IEnumerable<Transaction> returnFr(DateTime date)
    {
        var trade = from b in db.Transaction where b.createDate == date select b;
        return trade;
    }
}